﻿using System;

namespace SharpObservation
{
    /// <summary>
    /// Simple type for declaring event keys
    /// </summary>
    /// <typeparam name="TDelegate">The delegate type which the event represents</typeparam>
    /// <remarks>
    /// EventKey holds no functionality of it's own - it exists to serve two purposes:
    /// 1) To be a key in an EventHandlerList, and
    /// 2) To allow compile time type checking of the delegate type which the event represents
    /// </remarks>
    /// <example>
    /// private static readonly EventKey[PropertyChangedEventHandler]
    /// </example>
    public sealed class EventKey<TDelegate>
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="EventKey&lt;TDelegate&gt;"/> class.
        /// </summary>
        public EventKey()
        {
            if (!typeof(Delegate).IsAssignableFrom(typeof(TDelegate)))
                throw new GenericArgumentException(@"TDelegate must be a delegate type");
        }
    }
}